{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -4 + 7 i$"
      ],
      "text/plain": [
       "-4 + 7*I"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sympy as sy\n",
    "\n",
    "c = 1+2*sy.I\n",
    "# sy.arg(c).eval()\n",
    "\n",
    "c.as_real_imag() # 列出实部和虚部\n",
    "\n",
    "c.conjugate() # 共轭\n",
    "\n",
    "abs(c) # 模\n",
    "\n",
    "sy.arg(c)\n",
    "\n",
    "sy.S('(1+2j)*(2+3j)').simplify()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1.4916690547623055+0.5429231353094808j)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = 3+4j\n",
    "a = 4*np.exp(np.pi/3*1j) # 复数的指数形式，\n",
    "# a = (np.pi/3)*np.1i\n",
    "# a = np.complex64\n",
    "a\n",
    "np.angle(a) # a的幅角\n",
    "abs(a)\n",
    "\n",
    "np.sqrt(a) \n",
    "\n",
    "a**(1/3) # 如何算出a的其他根"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pytorch",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
